package com.group.app.example;


import com.group.app.example.repository.FieldNodeRepository;
import com.group.app.example.repository.FieldRepository;
import com.group.app.example.repository.FieldStationRepository;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


@RunWith(SpringRunner.class)
@SpringBootTest
public class FieldNodeDao {


    @Autowired
    private FieldNodeRepository fieldNodeRepository;

    @Autowired
    private FieldStationRepository fieldStationRepository;

    @Autowired
    FieldRepository fieldRepository;
    @Test
    public void getFieldNode(){
//        Pageable page=  PageRequest.of(1,2);
//        String name="引擎流";
//        String type=null;
//        fieldRepository.queryLabelInfo1(name, type);
        //List<FieldNodeModel> fieldNodeModels = fieldNodeRepository.queryLabelInfo("AAAA", "字符类型", page);
//        Specification<FieldStationModel> spec = new Specification<FieldStationModel>(){
//            //查询条件构造
//            @Override
//            public Predicate toPredicate(Root<FieldStationModel> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
//                Path<String> name = root.get("fieldName");
//                Predicate p1 = cb.like(name, "%"+name+"%");
//                Predicate p = cb.and(p1);
//                return p;
//            }
//
//        };
//        Page<FieldStationModel> fieldStationModels = fieldStationRepository.queryLabelInfo1(spec, page);
//        System.out.println(fieldStationModels);

//        FieldNodeModel fieldNodeModel=new FieldNodeModel();
//        fieldNodeModel.setId("a1d40999059b186696fa0e4d818b35bd");
//        fieldNodeModel.setName("引擎流-444444");
    }

//    @Test
//    public void findFieldNode(){
//        Pageable page=  PageRequest.of(1,5);
//        List<Map<String, Object>> maps = fieldNodeRepository.queryLabelInfo(new Specification<SearchVo>() {
//            @Override
//            public Predicate toPredicate(Root<SearchVo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
//                Path<String> fieldName = root.get("fieldName");
//                Path<String> fieldType = root.get("fieldType");
//                query.where(cb.like(fieldName, "%擎%"), cb.like(fieldType, "%8%"));
//                return null;
//            }
//        }, page);
//        System.out.println(maps);
//    }

    @Test
    public void findFieldNode(){
        String name="引擎流";
        String type="8";
        //SearchVo searchVo=new SearchVo(null,null,name,type);
//        List<Map<String, Object>> maps = fieldRepository.queryLabelInfo1(searchVo);
//        System.out.println(maps);
    }
}
